//
//  DGGAliyunOSSSDK.h
//  AliyunOSSiOS
//
//  Created by 胡中楷 on 2020/7/3.
//

#import <Foundation/Foundation.h>
#import <AliyunOSSiOS/OSSModel.h>

@interface DGGAliyunOSSSDK : NSObject

/// 系统sysKey，延签参数
@property (nonatomic, copy) NSString *sysKey;

/// 系统sysCode，区分系统
@property (nonatomic, copy) NSString *sysCode;

/// 项目的bucket，区分资源，不设置默认为dggtechtest
@property (nonatomic, copy) NSString *bucketName;

/// 阿里云 OSS 服务在各个区域的地址，示例：https://oss-cn-beijing.aliyuncs.com
@property (nonatomic, copy) NSString *endpoint;

/// 架构中心的上传回调地址，默认产线环境
@property (nonatomic, copy) NSString *callBackUrl;

/// 是否随机生成文件夹隔离，避免出现文件被覆盖的情况，默认NO
@property (nonatomic, assign) BOOL randomFolder;

/// 初始化方法
- (instancetype)initWithBucketName:(NSString *)bucketName
                          endpoint:(NSString *)endpoint
                           sysCode:(NSString *)sysCode
                            sysKey:(NSString *)sysKey;

/// 普通上传文件
- (void)dgg_uploadOSSWithFile:(NSData *)fileData
                     fileName:(NSString *)fileName
                   folderName:(NSString *)folderName
                     progress:(OSSNetworkingUploadProgressBlock)progressBlock
            completionHandler:(void(^)(NSDictionary *result, NSError *error))completion;

/// 普通上传文件-带参数fileId
- (void)dgg_uploadOSSWithFile:(NSData *)fileData
                     fileName:(NSString *)fileName
                   folderName:(NSString *)folderName
                       fileId:(NSString *)fileId
                       params:(NSDictionary *)params
                     progress:(OSSNetworkingUploadProgressBlock)progressBlock
            completionHandler:(void(^)(NSDictionary *result, NSError *error))completion;

/// 普通上传文件，本地地址
- (void)dgg_uploadOSSWithFileURL:(NSString *)filePath
                        fileName:(NSString *)fileName
                      folderName:(NSString *)folderName
                        progress:(OSSNetworkingUploadProgressBlock)progressBlock
               completionHandler:(void(^)(NSDictionary *result, NSError *error))completion;

/// 普通上传文件，本地地址-带参数fileId
- (void)dgg_uploadOSSWithFileURL:(NSString *)filePath
                        fileName:(NSString *)fileName
                      folderName:(NSString *)folderName
                          fileId:(NSString *)fileId
                          params:(NSDictionary *)params
                        progress:(OSSNetworkingUploadProgressBlock)progressBlock
               completionHandler:(void(^)(NSDictionary *result, NSError *error))completion;

/// 分片上传 - 指定分片数量
- (void)dgg_multipartUploadOSSWithFileURL:(NSString *)filePath
                               chuckCount:(NSInteger)chuckCount
                                 fileName:(NSString *)fileName
                               folderName:(NSString *)folderName
                                   fileId:(NSString *)fileId
                                 progress:(OSSNetworkingUploadProgressBlock)progressBlock completionHandler:(void(^)(NSDictionary *result, NSError *error))completion;

/// 分片上传 - 自动计算分片数量
- (void)dgg_multipartUploadOSSWithFileURL:(NSString *)filePath
                                 fileName:(NSString *)fileName
                               folderName:(NSString *)folderName
                                   fileId:(NSString *)fileId
                                 progress:(OSSNetworkingUploadProgressBlock)progressBlock
                        completionHandler:(void(^)(NSDictionary *result, NSError *error))completion;

/// 下载文件，objectKey等同于objectName，表示从OSS下载文件时需要指定包含文件后缀在内的完整路径，例如abc/efg/123.jpg
- (void)dgg_downloadOSSWithFileKey:(NSString *)objectKey
                         toFileURL:(NSURL *)fileURL
                          progress:(OSSNetworkingDownloadProgressBlock)progressBlock
                 completionHandler:(void (^)(NSDictionary *result, NSError *error))completion;

@end
